package com.orphan.util.mqConfig;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PromotionMq {
    @Autowired
    CachingConnectionFactory cachingConnectionFactory;
    //创建队列
//    @Bean(value = "rabbitTemplate")
//    public RabbitTemplate rabbitTemplate(){
//        return new RabbitTemplate(cachingConnectionFactory);
//    }
    @Bean
    public Queue queueProm(){
        return new Queue("queueProm");
    }
    //创建默认交换机
    @Bean
    public DirectExchange directExchangeProm(){
        return new DirectExchange("directExchangeProm" );
    }
    //把队列绑定到交换机
    @Bean
    public Binding PromotionEX(Queue queueProm, DirectExchange directExchangeProm){
        return BindingBuilder.bind(queueProm).to(directExchangeProm).with("Promotion");
    }

}
